								<table id="sample-table-2" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th style="width:5%">序号</th>
											<th style="width:8%">51M货号</th>
											<th style="width:8%">条形码</th>
											<th style="width:10%">名称</th>
											<th style="width:8%">商品属性</th>
											<th style="width:10%">价格($)(不含GST)</th>
											<th style="width:8%">GST($)</th>
											<th style="width:10%">公共仓库存</th>
											<th style="width:10%">虚拟仓库存</th>
											<th style="width:8%">采购数量</th>
											<th style="width:8%" >协商价格($)</th>
											<th style="width:8%" >有效期</th>
											<th style="width:8%">预估交货时间</th>
											<th style="width:5%">操作</th>
										</tr>
									</thead>
									<tbody>
										<volist name="lists['lists']" id="vo">
											<tr>

												<td>
													<a href="#">{$i}</a>
												</td>
												<td >{$vo.goods_sn}</td>
												<td >{$vo.bar_code}</td>
												<td >{$vo.goods_name}</td>
												<td>{$vo.attribute_text|default ="/"}</td>
												<td>{$vo.goods_price }</td>
												<td>{$vo.taxrate}</td>
												<td>{$vo.quantity}</td>
												<td >{$vo.my_quantity }</td>
											    <td><input type="number" style="width:50px" min="0" value="0" name="number"></td>
											    <td><input type ="text" style="width:50px"  name="price"></td>
											    <td><select class="form-control" name="validity"  style="width:80px" id="form-field-select-1">
																<option value="0">无限制</option>
																<option value="1">一个月</option>
																<option value="3">三个月</option>
																<option value="6">半年</option>
																<option value="12">一年</option>
																<option value="24">两年</option>
															</select></td>
											    <td> <div class="input-group" style="width:150px" ><input    onclick="laydates($(this).attr('id'))" class="form-control date-picker expire_time " id="expire_time_{$i}" type="text" name="expire_time" data-date-format="dd-mm-yyyy" size="15"><span class="input-group-addon" ><i class="icon-calendar bigger-110"></i></span></div></td>
                                                 <td >
                                                 <button type="button" class="btn btn-sm btn-success" goodsSn="{$vo.goods_sn}"  onclick="join_pre_order(this)"  > 加入预订单</button></td>
                                               
											</tr>
										</volist>
									</tbody>
								</table>
							
					<table style="width: 80%; float: right; margin-bottom:10px">
					    <tr>
					        <td style="text-align: right;"> <div class="page_list_ops dataTables_paginate paging_bootstrap pagination" >{$lists['page_html']}</div></td>
					    </tr>
					</table>

<script type="text/javascript">
var cookiename="pre_order_<?php echo UID; ?>";

function laydates(id){
    laydate({
        elem: '#'+id,
        festival: true, //显示节日
        istime: true,
        min: laydate.now(),
        start: laydate.now(0,"YYYY/MM/DD "),  //设置开始时间为当前时间
        // format: 'YYYY-MM-DD hh:mm:ss'
        format: 'YYYY-MM-DD'
    })	
}

//加入预订单
 function join_pre_order(_this){
   var goods_sn = $(_this).attr('goodsSn');
   var time = $(_this).parent('td').prev().find('input').val();
   var validity = $(_this).parent('td').prev().prev().find('select').val();
   var price =$(_this).parent('td').prev().prev().prev().find('input').val();
   var number =$(_this).parent('td').prev().prev().prev().prev().find('input').val();
	if ( number<=0 ||number =="" ) {
	    showvfmsg(0, '数量填写有误', 2000);
	    return ;
	}
	var ex = /^\d+(\.\d+)?$/;
	if (price=="" || !ex.test(price) ) {
	    showvfmsg(0, '价格填写有误', 2000);
	    return ;
	}
	if (time=="" ) {
	    showvfmsg(0, '请选择有效时间', 2000);
	    return ;
	}

	if (validity=="" ) {
	    showvfmsg(0, '请选择到期时间', 2000);
	    return ;
	}
	var arr = {};
	 arr['GoodsSn'] = goods_sn;
	 arr['price'] = price;
	 arr['Quantity'] = number;
	 arr['Validity'] = validity;
	 arr['Delivery'] = get_unix_time(time);
	var ojson = [],ojson = [];
    var _list=getCookie(cookiename);
    if(_list !=null && _list!="" ){
       ojson=JSON.parse(_list);
    } 
        //从cookie中获取的值哪些需要删除，哪些需要更新 
/*    for(var i=0;i<ojson.length;i++){ 
         if(ojson[i]['GoodsSn']==arr['GoodsSn']){ 
           
        }else{
          json.push(ojson[i]);  //不相等添加
        }
    } */
	var bl=isExist(ojson,arr['GoodsSn']);
    //如果是勾选并且是不存在cookie记录新时，增加
    if(!bl ){ojson.push(arr);}else{showvfmsg(0, '该商品已近采购了', 2000);return;}
     var count = ojson.length;
     $('#pre_order_count').html('+'+count);
    var _json=JSON.stringify(ojson);
    //考虑重复记录的清理。 
    setCookie(cookiename,"",-10);
    setCookie(cookiename,_json,1);
	 showvfmsg(1, '添加成功', 2000);
    setTimeout(function(){ 
        load();
    },1000);
  
    
 }

 //判断json数据中是否存在商品编号id
 function isExist(ary,val){
      var flg=false;
      if(ary==null || ary.length==0)return flg;
      for(var i=0;i<ary.length;i++){
          if(ary[i]['GoodsSn']==val){
              flg=true;
              break;
          }
      }
      return flg;
 }
function get_unix_time(dateStr)
{
    var newstr = dateStr.replace(/-/g,'/'); 
    var date =  new Date(newstr); 
    var time_str = date.getTime().toString();
    return time_str.substr(0, 10);
}

 function _es_openDilog90(url, title,id){ 
     art.dialog.open(url, { title: title, width: '1000px', height: '80%', opacity: 0.2, id: id, fixed: true, close:function(){load();}  });
}


//写入cookie
 function setCookie(c_name, value, expiredays){
    if(expiredays < 0){
        localStorage.removeItem(c_name);
    }
       localStorage.setItem(c_name,value); //存储名字为name值为caibin的变量
 }
//读取cookie   
 function getCookie(c_name){
    return  localStorage.getItem(c_name);
 }

</script>